var user_data = {};

function background_main()
{
  debug("Background Thread started");
  chrome.browserAction.onClicked.addListener(openLoginTab);
}

function openLoginTab() 
{
  debug("Popup clicked, opening new tab.");
	chrome.tabs.create({url: "html/login.html", pinned: true});
}

function saveUserData(userDataObj)
{
  debug("Data saved for tab id:"+userDataObj.tabId);
  user_data[userDataObj.tabId] = userDataObj;
}

function getUserDataForTab(tabId)
{
  var userData = user_data[tabId];

  if(!userData)
    throw("No user data found for tab:"+tabId);

  return userData;
}
